home *** CD-ROM | disk | FTP | other *** search
- /*--------------------------------------------------------------------------*/
- /* */
- /* */
- /* ------------ Bit-Bucket Software <no-Inc> */
- /* \ 10001101 / Writers and Distributors of */
- /* \ 011110 / No-Cost<no-tm> Software. */
- /* \ 1011 / */
- /* ------ */
- /* */
- /* Copyright (C) 1987, 1988, 1989 by Robert Hartman and Vincent Perriello */
- /* */
- /* */
- /* This module was written by Vince Perriello */
- /* */
- /* */
- /* BinkleyTerm File Request Failure Message Module */
- /* */
- /* */
- /* For complete details of the licensing restrictions, please refer */
- /* to the License agreement, which is published in its entirety in */
- /* the MAKEFILE and BT.C, and also contained in the file LICENSE.210. */
- /* */
- /* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
- /* BINKLEYTERM LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
- /* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
- /* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT THE AUTHORS */
- /* AT THE ADDRESSES LISTED BELOW. IN NO EVENT SHOULD YOU PROCEED TO */
- /* USE THIS FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE */
- /* BINKLEYTERM LICENSING AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU */
- /* ARE ABLE TO REACH WITH THE AUTHORS. */
- /* */
- /* */
- /* The Authors can be reached at the following addresses: */
- /* */
- /* Robert C. Hartman Vincent E. Perriello */
- /* Spark Software VEP Software */
- /* 427-3 Amherst Street 111 Carroll Street */
- /* CS2032, Suite 232 Naugatuck, CT 06770 */
- /* Nashua, NH 03061 */
- /* */
- /* FidoNet 1:132/101 FidoNet 1:141/491 */
- /* Data (603) 888-8179 Data (203) 729-7569 */
- /* */
- /* Please feel free to contact us at any time to share your comments */
- /* about our software and/or licensing policies. */
- /* */
- /*--------------------------------------------------------------------------*/
- #include <stdio.h>
- #include <time.h>
- #include <ctype.h>
- #include <string.h>
- #include <stdlib.h>
-
- #ifdef __TURBOC__
- #include <mem.h>
- #include <alloc.h>
- #else
- #include <memory.h>
- #include <malloc.h>
- #endif
-
- #define WAZOO_SECTION
- #include "com.h"
- #include "xfer.h"
- #include "zmodem.h"
- #include "keybd.h"
- #include "sbuf.h"
- #include "sched.h"
- #include "externs.h"
- #include "prototyp.h"
-
- void Make_Response(char *, int); /* Build a response */
-
- void Make_Response (data, failure)
- char *data; /* input = response, output = filename */
- int failure; /* failure code from file req module */
- {
- FILE *Template, *Response;
- char *dummy_text;
- char *text;
- char *failure_text[10];
- char resp_filename[13];
- char *p, *q, *s;
- struct tm *tp;
- time_t ltime;
- int i;
-
- Template = Response = NULL;
-
- for (i = 0; i < 9; i++)
- failure_text[i] = NULL;
-
- if (((text = malloc (256)) == NULL)
- || ((dummy_text = malloc (256)) == NULL))
- goto resp_failed;
-
- time (<ime);
- tp = localtime (<ime);
-
- errno = 0;
- Template = fopen (CurrentReqTemplate, read_ascii);
- if (got_error (OPEN_msg, CurrentReqTemplate))
- goto resp_failed;
-
- sprintf (resp_filename, "%04x%04x.RSP", alias[assumed].Net, alias[assumed].Node);
- Response = fopen (resp_filename, write_binary);
- if (got_error (OPEN_msg, resp_filename))
- goto resp_failed;
-
- while (!feof (Template))
- {
-
- read_line:
-
- e_input[0] = '\0';
- if (fgets (text, 254, Template) == NULL)
- break;
-
- if (text[0] == '%' && text[1] == ';')
- continue; /* Comment at start, no output */
-
- p = text;
- q = e_input;
-
- while (*p)
- {
-
- if (*p == '\n') /* All done if newline seen */
- break;
-
- if (*p != '%') /* Copy until(unless) we see % */
- {
- *q++ = *p++;
- continue;
- }
-
- if (*++p == ';') /* If followed by ; just skip */
- break;
-
- if ((i = parse(p, rspverbs)) == -1)/* Check against arg list */
- {
- *q++ = '%'; /* No match, use the % literal */
- continue;
- }
-
- switch (i)
-
- {
-
- case 1: /* "text" */
-
- if (((i = atoi (p = skip_blanks (&p[4]))) < 1) || (i > 9))
- goto read_line;
-
- if (!*(p = skip_to_blank (p)) || !*++p)
- goto read_line;
-
- if (failure_text[--i] != NULL)
- free(failure_text[i]);
-
- failure_text[i] = s = malloc (1 + strlen (p));
- if (s == NULL)
- goto read_line;
- while ((*p) && (*p != '\n'))
- *s++ = *p++;
- *s++ = '\0';
-
- goto read_line;
-
- case 2: /* "date" */
- p += 4;
- sprintf (dummy_text,"%2d-%3s-%02d", tp->tm_mday, mtext[tp->tm_mon], tp->tm_year);
- scopy:
- s = dummy_text;
- ccopy:
- while (*s)
- *q++ = *s++;
-
- break;
-
- case 3: /* "time" */
- p += 4;
- sprintf (dummy_text, "%2d:%02d", tp->tm_hour, tp->tm_min);
- goto scopy;
-
- case 4: /* "bink" */
- p += 4;
- s = ANNOUNCE;
- goto ccopy;
-
- case 5: /* "mynode" */
- p += 6;
- sprintf (dummy_text, "%i:%i/%i.%i",
- alias[assumed].Zone, alias[assumed].Net, alias[assumed].Node, alias[assumed].Point);
- goto scopy;
-
- case 6: /* "system" */
- p += 6;
- s = system_name;
- goto ccopy;
-
- case 7: /* "sysop" */
- p += 5;
- s = sysop;
- goto ccopy;
-
- case 8: /* "yrnode" */
- p += 6;
- sprintf (dummy_text, "%i:%i/%i.0", remote_zone, remote_net, remote_node);
- goto scopy;
-
- case 9: /* "request" */
- p += 7;
- s = data;
- goto ccopy;
-
- case 10: /* "status" */
- p += 6;
- strcpy (dummy_text, p);
- strcpy (text, failure_text [failure-1]);
- strcat (text, dummy_text);
- p = text;
- break;
-
- case 11: /* "abort" */
-
- if (*(p = skip_blanks (&p[5])))/* If there's an argument, */
- {
- if (failure != atoi (p))/* See if it matches failure */
- goto read_line; /* No, keep going. */
- }
-
- fclose (Response); /* Abort things: Close file, */
- Response = NULL; /* Keep track of closed file */
- unlink (resp_filename); /* Then delete it */
- goto resp_failed; /* And take the failure exit */
-
- case 12: /* "exit" */
-
- if (*(p = skip_blanks (&p[4])))/* If there's an argument, */
- {
- if (failure != atoi (p))/* See if it matches failure */
- goto read_line; /* No, keep going. */
- }
-
- else goto resp_done; /* A match, close the file */
-
- case 13: /* "line" */
-
- if ((!(*(p = skip_blanks (&p[4]))))
- || (failure != atoi (p))) /* If argument doesn't match, */
- goto read_line; /* throw out line, keep going. */
- if (*(p = skip_to_blank (p))) /* If there's any text, */
- {
- strcpy (text, ++p); /* Copy rest of line down */
- p = text; /* Move pointer to front */
- }
- break;
-
- } /* End switch */
- } /* End while *p */
-
- *q++ = '\r';
- *q++ = '\n';
- *q = '\0';
-
- errno = 0;
- i = q - e_input;
- fwrite (e_input, i, 1, Response);
- if (got_error (WRITE_msg, resp_filename))
- goto resp_failed;
-
- } /* End while !feof (Template) */
-
- resp_done:
-
- strcpy (data, resp_filename);
-
- fclose (Template);
- Template = NULL;
-
- errno = 0;
- fclose (Response);
- Response = NULL;
- if (!got_error (CLOSE_msg, resp_filename))
- goto cleanup;
-
- resp_failed:
-
- *data = '\0';
-
- if (Response != NULL)
- fclose (Response);
-
- if (Template != NULL)
- fclose (Template);
-
- cleanup:
-
- for (i = 0; i < 9; i++)
- {
- if (failure_text[i] != NULL)
- {
- free(failure_text[i]);
- failure_text[i] = NULL;
- }
- }
-
- if (text != NULL)
- free (text);
-
- if (dummy_text != NULL)
- free (dummy_text);
-
- return;
- }
-